<?php
namespace app\index\controller;

use think\Controller;

class Index extends Controller
{

    public function _tpl()
    {
        $this->assign('header',$this->fetch('templates/index/header.html'));
        $this->assign('footer',$this->fetch('templates/index/footer.html'));
    }

    public function index()
    {

        $arr=db('company')->find();
        dump($arr);
        $str='<xml>
        <SuiteId><![CDATA[tj4asffe99e54c0f4c]]></SuiteId>
        <AuthCorpId><![CDATA[wxf8b4f85f3a794e77]]></AuthCorpId>
        <InfoType><![CDATA[change_contact]]></InfoType>
        <TimeStamp>1403610513</TimeStamp>
        <ChangeType><![CDATA[create_user]]></ChangeType>
        <UserID><![CDATA[zhangsan]]></UserID>
        <Name><![CDATA[张三]]></Name>
        <Department><![CDATA[1,2,3]]></Department>
        <Mobile><![CDATA[15913215421]]></Mobile>
        <Position><![CDATA[产品经理]]></Position>
        <Gender>1</Gender>
        <Email><![CDATA[zhangsan@gzdev.com]]></Email>
        <Avatar><![CDATA[http://wx.qlogo.cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0]]></Avatar>
        <EnglishName><![CDATA[zhangsan]]></EnglishName>
        <IsLeader>1</IsLeader>
        <Telephone><![CDATA[020-3456788]]></Telephone>
        <ExtAttr>
            <Item>
            <Name><![CDATA[爱好]]></Name>
            <Value><![CDATA[旅游]]></Value>
            </Item>
            <Item>
            <Name><![CDATA[卡号]]></Name>
            <Value><![CDATA[1234567234]]></Value>
            </Item>
        </ExtAttr>
    </xml>';
        $xml = new \DOMDocument();
        $xml->loadXML($str);
        echo $xml->getElementsByTagName('Gender')->item(0)->nodeValue;

        /*
        $res=model('Qywx')->get_permanent_code('la1rPyCHfH4nXFrfA11Smik_vVhHyl3LXctwY9ZrcmJM0CnCq-VX2ASKJcln9sbZlyOJM9Vc9WZYfcd1Pw4haLQ95BcrSeys2QAg_n7XrCA');
        $js=json_decode($res,true);
        dump($js);
        */

        /*
        $res=model('Qywx')->get_auth_info('TUFjOE-usr-FhqzF5yMw2LtTT3lqBserPb1xi0XFr3I','wwd2ce7d0a0568e88a');
        $js=json_decode($res,true);
        dump($js);
        */
        /*
        $str='{"access_token":"QlgdD1UU9UsneeZQoximNwqekXV2vxv9Jfico7yrsqMvvv3jCbjqTITOkwNlqWXRm7hW5sZsKIq2FlRE1izfO7hqpOE9lB-zRUOdwQ9VeIf68w_8ykspsIvZELk4NN2QbXmP3-mYvqWkeJRV4WajQfLzBMOXLoNi8_5ItggfBXRxo1tATWQGltTDV928IqDs_ySaqOgkHxVOBkVBjeujqw","expires_in":7200,"permanent_code":"LkVFwOjqk_PaVSY4NGSoEOK-E2KYgdF72OqQPa_Xuuk","auth_corp_info":{"corpid":"wwd2ce7d0a0568e88a","corp_name":"测试企业","corp_type":"unverified","corp_round_logo_url":"","corp_square_logo_url":"http:\/\/p.qlogo.cn\/bizmail\/86RSsSTBzNxNeT2bSQicF8Qd63y6n5gSlm2yEWnyibBBtMBPsEFWIic2A\/0","corp_user_max":200,"corp_agent_max":0,"corp_wxqrcode":"http:\/\/p.qpic.cn\/pic_wework\/2901281542\/181e13118b149bb6520f36bee41f9c40ef54b75c90e39c08\/0","corp_full_name":"","subject_type":1,"verified_end_time":0},"auth_info":{"agent":[{"agentid":1000177,"name":"测试应用","square_logo_url":"https:\/\/p.qlogo.cn\/bizmail\/Qtjsd8wUcLAGw27sbFTMZsHXPdC8U5fZBDMahwV8utb2RbZcVF2dBw\/0","appid":1,"api_group":[],"privilege":{"level":1,"allow_party":[1],"allow_user":[],"allow_tag":[],"extra_party":[],"extra_user":[],"extra_tag":[]}},{"agentid":1000178,"name":"测试应用2","square_logo_url":"https:\/\/p.qlogo.cn\/bizmail\/Qtjsd8wUcLAGw27sbFTMZsHXPdC8U5fZ2E19HKaqTOyF1q0ztQPAmA\/0","appid":2,"api_group":[],"privilege":{"level":1,"allow_party":[1],"allow_user":[],"allow_tag":[],"extra_party":[],"extra_user":[],"extra_tag":[]}}],"department":[]},"auth_user_info":{"userid":"LiaoZhenHao","name":"廖振皓","mobile":"17130710214","email":"","avatar":"http:\/\/p.qlogo.cn\/bizmail\/o5Dw7cUOdyibS1WUStwpcHzB4yvf7A1Jt44FB2F7I62t8KOcmXCz8NQ\/0"}}';
        $js=json_decode($str,true);
        dump($js);
        echo $js['auth_corp_info']['corpid'];
        */
        /*
        echo model('Qywx')->get_suite_token();
        $str='<xml><SuiteId><![CDATA[tj8246c20bede579d5]]></SuiteId><AuthCode><![CDATA[la1rPyCHfH4nXFrfA11SmpJLwUiZ02Cglj9ttpwrr1IoCnf89-d_P9kyz8BIRFbSaMveN3OvDG3WNtb25ox7dEx3_yH4t_Pzc609KzQGk5U]]></AuthCode><InfoType><![CDATA[create_auth]]></InfoType><TimeStamp>1510641694</TimeStamp></xml>';
        $xml = new \DOMDocument();
        $xml->loadXML($str);
        echo $AuthCode = $xml->getElementsByTagName('AuthCode')->item(0)->nodeValue;
        echo '<br>';
        echo $AuthCode = $xml->getElementsByTagName('InfoType')->item(0)->nodeValue;
        */

        echo '<h3>网站正在调试中</h3>';
        exit;
        $this->_tpl();
        return $this->fetch('templates/index/index.html');
    }
    function test()
    {
        $str='{"access_token":"BklNuiIFhn7NJvlXng-DeexnPFFOMmrMTd9kpkavzZUeeOesMkyYBzIezkpDxwceaAKTXhkKmeY7wFsUjl0Q_-4L7GMsRq2qGjFEyww_ZWgjge-K4RJdy9Xydmcpj1ftRbYaoSjeQGD2QhSIIcd7028YVUmFh_Ydc8K5tAQYh4RGTvq1znSiLq50p3zgCHT8qldilJGhQLets4HTnZEOmQ","expires_in":7200,"permanent_code":"wBk3oTUdEqgcUPsVd8FAxuCo-ySBjnhV6G-ZNpMh6QU","auth_corp_info":{"corpid":"wwd2ce7d0a0568e88a","corp_name":"测试企业","corp_type":"unverified","corp_round_logo_url":"","corp_square_logo_url":"http://p.qlogo.cn/bizmail/86RSsSTBzNxNeT2bSQicF8Qd63y6n5gSlm2yEWnyibBBtMBPsEFWIic2A/0","corp_user_max":200,"corp_agent_max":0,"corp_wxqrcode":"http://p.qpic.cn/pic_wework/2901281542/181e13118b149bb6520f36bee41f9c40ef54b75c90e39c08/0","corp_full_name":"","subject_type":1,"verified_end_time":0},"auth_info":{"agent":[{"agentid":1000242,"name":"办公用品管理","square_logo_url":"https://p.qlogo.cn/bizmail/Qtjsd8wUcLAGw27sbFTMZsHXPdC8U5fZPtgV3852VyJtsA9ylP2xxQ/0","privilege":{"level":1,"allow_party":[1],"allow_user":[],"allow_tag":[],"extra_party":[],"extra_user":[],"extra_tag":[]}}]},"auth_user_info":{"userid":"lzh","mobile":"17130710214","email":"","name":"廖振皓","avatar":"http://p.qlogo.cn/bizmail/o5Dw7cUOdyibS1WUStwpcHzB4yvf7A1Jt44FB2F7I62t8KOcmXCz8NQ/0"}}';
        $arr=json_decode($str,true);
        dump($arr);
    }
}
